package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.ApUserRelationDTO;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.IApUserRelationService;
import com.heima.user.service.IApUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "APP 端文章详情页 API")
@RestController
@RequestMapping("api/v1/user")
public class ApUserController {

    @Autowired
    private IApUserRelationService apUserRelationService;
    @Autowired
    private IApUserService apUserService;

    @ApiOperation(value = "文章详情页用户关注/取关 API", notes = "文章详情页用户关注/取关 API")
    @PostMapping("user_follow")
    public ResponseResult follow(@RequestBody ApUserRelationDTO apUserRelationDTO){
        return apUserRelationService.follow(apUserRelationDTO);
    }

    @ApiOperation(value = "查询 APP 用户信息", notes = "评论微服务通过用户 id 远程调用查询")
    @PostMapping("/{id}")
    public ResponseResult<ApUser> findUserById(@PathVariable(value = "id") Integer id){
        return ResponseResult.okResult(apUserService.getById(id));
    }
}
